#include "widget.h"
#include "ui_widget.h"
#include <QPixmap>
#include<QPushButton>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    QPixmap pixmap(":/image/dog.jpg");

    //QIcon icon(":/dog.jpg");
    ui->label->setPixmap(pixmap);
    QIcon icon(":/image/up.png");
    ui->pushButton_up->autoRepeatDelay();
    ui->pushButton_up->setIcon(icon);
    ui->pushButton_up->setShortcut('W');
    ui->pushButton_down->autoRepeat();
    ui->pushButton_down->setIcon(QIcon(":/image/down.png"));
    ui->pushButton_down->setShortcut('S');
    ui->pushButton_left->setIcon(QIcon(":/image/left.png"));
    ui->pushButton_left->autoRepeat();
    ui->pushButton_right->setIcon(QIcon(":/image/right.png"));
    ui->pushButton_right->autoRepeat();
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_up_clicked()
{
    QRect rect = ui->label->geometry();
    ui->label->setGeometry(rect.x(),rect.y()-5,rect.width(),rect.height());
}
void Widget::on_pushButton_down_clicked()
{
    QRect rect = ui->label->geometry();
    ui->label->setGeometry(rect.x(),rect.y()+5,rect.width(),rect.height());
}
void Widget::on_pushButton_left_clicked()
{
    QRect rect = ui->label->geometry();
    ui->label->setGeometry(rect.x()-5,rect.y(),rect.width(),rect.height());
}
void Widget::on_pushButton_right_clicked()
{
    QRect rect = ui->label->geometry();
    ui->label->setGeometry(rect.x()+5,rect.y(),rect.width(),rect.height());
}


